<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue3 响应式基础实例演示</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }

        .header {
            text-align: center;
            margin-bottom: 40px;
        }

        .header h1 {
            font-size: 2.5rem;
            color: #2c3e50;
            margin-bottom: 10px;
            background: linear-gradient(45deg, #42b883, #3eaf7c);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .header p {
            font-size: 1.1rem;
            color: #7f8c8d;
            margin-bottom: 20px;
        }

        .intro {
            background: linear-gradient(135deg, #42b883, #3eaf7c);
            color: white;
            padding: 25px;
            border-radius: 15px;
            margin-bottom: 30px;
            text-align: center;
        }

        .intro h2 {
            margin-bottom: 15px;
            font-size: 1.5rem;
        }

        .intro p {
            line-height: 1.6;
            opacity: 0.9;
        }

        .examples-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
            gap: 25px;
            margin-bottom: 30px;
        }

        .example-card {
            background: white;
            border-radius: 15px;
            padding: 25px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            border-left: 5px solid #42b883;
        }

        .example-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
        }

        .example-card h3 {
            color: #2c3e50;
            font-size: 1.3rem;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .example-card .icon {
            font-size: 1.5rem;
        }

        .example-card .description {
            color: #7f8c8d;
            margin-bottom: 15px;
            line-height: 1.5;
        }

        .example-card .features {
            list-style: none;
            margin-bottom: 20px;
        }

        .example-card .features li {
            color: #34495e;
            margin-bottom: 8px;
            padding-left: 20px;
            position: relative;
        }

        .example-card .features li::before {
            content: "✨";
            position: absolute;
            left: 0;
        }

        .example-actions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9rem;
            font-weight: 500;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .btn-primary {
            background: linear-gradient(135deg, #42b883, #3eaf7c);
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(66, 184, 131, 0.4);
        }

        .btn-secondary {
            background: rgba(66, 184, 131, 0.1);
            color: #42b883;
            border: 1px solid rgba(66, 184, 131, 0.3);
        }

        .btn-secondary:hover {
            background: rgba(66, 184, 131, 0.2);
        }

        .section-divider {
            margin: 40px 0;
            text-align: center;
            position: relative;
        }

        .section-divider::before {
            content: "";
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background: linear-gradient(90deg, transparent, #42b883, transparent);
        }

        .section-divider span {
            background: white;
            padding: 0 20px;
            color: #42b883;
            font-weight: bold;
            position: relative;
        }

        .footer {
            text-align: center;
            margin-top: 40px;
            padding-top: 30px;
            border-top: 1px solid #ecf0f1;
            color: #7f8c8d;
        }

        .footer p {
            margin-bottom: 10px;
        }

        .tech-stack {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-top: 15px;
        }

        .tech-item {
            background: rgba(66, 184, 131, 0.1);
            color: #42b883;
            padding: 8px 15px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 500;
        }

        @media (max-width: 768px) {
            .container {
                padding: 20px;
                margin: 10px;
            }

            .header h1 {
                font-size: 2rem;
            }

            .examples-grid {
                grid-template-columns: 1fr;
                gap: 20px;
            }

            .example-card {
                padding: 20px;
            }

            .example-actions {
                flex-direction: column;
            }

            .btn {
                justify-content: center;
            }
        }

        .highlight {
            background: linear-gradient(135deg, #ff6b6b, #ee5a52);
            color: white;
            padding: 2px 8px;
            border-radius: 4px;
            font-weight: bold;
        }

        .code-preview {
            background: #2c3e50;
            color: #ecf0f1;
            padding: 15px;
            border-radius: 8px;
            font-family: 'Courier New', monospace;
            font-size: 0.85rem;
            margin: 10px 0;
            overflow-x: auto;
        }

        .difficulty-badge {
            display: inline-block;
            padding: 4px 12px;
            border-radius: 15px;
            font-size: 0.7rem;
            font-weight: bold;
            text-transform: uppercase;
        }

        .difficulty-easy {
            background: rgba(40, 167, 69, 0.2);
            color: #28a745;
        }

        .difficulty-medium {
            background: rgba(255, 193, 7, 0.2);
            color: #ffc107;
        }

        .difficulty-hard {
            background: rgba(220, 53, 69, 0.2);
            color: #dc3545;
        }
    </style>
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 Vue3 响应式基础实例演示</h1>
            <p>通过8个精心设计的实例，掌握Vue3响应式系统的核心概念</p>
            <div class="tech-stack">
                <span class="tech-item">Vue3 Composition API</span>
                <span class="tech-item">TypeScript</span>
                <span class="tech-item">响应式数据</span>
                <span class="tech-item">计算属性</span>
                <span class="tech-item">侦听器</span>
            </div>
        </header>

        <section class="intro">
            <h2>🎯 学习路径</h2>
            <p>这套实例按照从基础到进阶的顺序设计，每个实例都包含完整的代码、详细的注释和实际应用场景。通过动手实践，你将深入理解Vue3的响应式原理，掌握ref、reactive、computed、watch等核心API的使用技巧。</p>
        </section>

        <div class="examples-grid">
            <!-- 关卡1: ref基础 -->
            <div class="example-card">
                <h3><span class="icon">⚔️</span> 关卡1: 英雄血量和攻击状态</h3>
                <span class="difficulty-badge difficulty-easy">初级</span>
                <p class="description">
                    学习Vue3最基础的响应式API - ref。通过英雄角色的血量和攻击状态管理，理解ref的声明、读取和修改方式。
                </p>
                <ul class="features">
                    <li>使用ref创建响应式数据</li>
                    <li>实现英雄血量管理</li>
                    <li>攻击状态切换动画</li>
                    <li>生命值自动恢复机制</li>
                </ul>
                <div class="code-preview">
const heroHP = ref(100)
const isAttacking = ref(false)
// 响应式数据自动更新UI
                </div>
                <div class="example-actions">
                    <a href="#" class="btn btn-primary" onclick="loadExample('01-ref-hero-example')">🎮 开始游戏</a>
                    <a href="#" class="btn btn-secondary" onclick="viewCode('01-ref-hero-example')">👀 查看代码</a>
                </div>
            </div>

            <!-- 关卡2: reactive进阶 -->
            <div class="example-card">
                <h3><span class="icon">🧙‍♂️</span> 关卡2: Vue法师成长记</h3>
                <span class="difficulty-badge difficulty-easy">初级</span>
                <p class="description">
                    掌握reactive API的使用场景，学习如何管理复杂的对象状态。通过法师角色的成长系统，体验reactive的强大功能。
                </p>
                <ul class="features">
                    <li>使用reactive管理复杂对象</li>
                    <li>法师等级和经验系统</li>
                    <li>技能树解锁机制</li>
                    <li>等级奖励自动发放</li>
                </ul>
                <div class="code-preview">
const mage = reactive({
  level: 1,
  experience: 0,
  skills: []
})
                </div>
                <div class="example-actions">
                    <a href="#" class="btn btn-primary" onclick="loadExample('02-reactive-hero-leveling')">🧙‍♂️ 开始冒险</a>
                    <a href="#" class="btn btn-secondary" onclick="viewCode('02-reactive-hero-leveling')">👀 查看代码</a>
                </div>
            </div>

            <!-- 关卡3: computed计算属性 -->
            <div class="example-card">
                <h3><span class="icon">🛒</span> 关卡3: 智能购物车</h3>
                <span class="difficulty-badge difficulty-medium">中级</span>
                <p class="description">
                    深入理解computed计算属性的原理和应用。通过购物车实例，学习如何创建高效的计算属性，实现自动价格计算。
                </p>
                <ul class="features">
                    <li>computed计算属性缓存机制</li>
                    <li>购物车商品管理</li>
                    <li>自动计算总价和折扣</li>
                    <li>实时价格变动监控</li>
                </ul>
                <div class="code-preview">
const totalPrice = computed(() => {
  return cartItems.value.reduce((sum, item) => 
    sum + item.price * item.quantity, 0)
})
                </div>
                <div class="example-actions">
                    <a href="#" class="btn btn-primary" onclick="loadExample('03-computed-shopping-cart')">🛍️ 开始购物</a>
                    <a href="#" class="btn btn-secondary" onclick="viewCode('03-computed-shopping-cart')">👀 查看代码</a>
                </div>
            </div>

            <!-- 关卡4: watch侦听器 -->
            <div class="example-card">
                <h3><span class="icon">👁️</span> 关卡4: 智能监控系统</h3>
                <span class="difficulty-badge difficulty-medium">中级</span>
                <p class="description">
                    掌握watch和watchEffect的使用区别，学习如何响应数据变化执行副作用操作。通过监控系统理解侦听器的工作原理。
                </p>
                <ul class="features">
                    <li>watch vs watchEffect对比</li>
                    <li>定点监控vs AI巡检</li>
                    <li>异常数据自动报警</li>
                    <li>监控日志实时记录</li>
                </ul>
                <div class="code-preview">
watch(data, (newVal, oldVal) => {
  console.log('数据变化:', oldVal, '->', newVal)
})
                </div>
                <div class="example-actions">
                    <a href="#" class="btn btn-primary" onclick="loadExample('04-watch-watchEffect-demo')">👁️ 开始监控</a>
                    <a href="#" class="btn btn-secondary" onclick="viewCode('04-watch-watchEffect-demo')">👀 查看代码</a>
                </div>
            </div>

            <!-- 关卡5: TypeScript集成 -->
            <div class="example-card">
                <h3><span class="icon">🎯</span> 关卡5: TypeScript类型推断</h3>
                <span class="difficulty-badge difficulty-medium">中级</span>
                <p class="description">
                    学习如何在Vue3中完美集成TypeScript，掌握ref和reactive的类型推断机制，编写类型安全的响应式代码。
                </p>
                <ul class="features">
                    <li>TypeScript类型推断演示</li>
                    <li>ref泛型类型使用</li>
                    <li>reactive复杂类型定义</li>
                    <li>类型安全最佳实践</li>
                </ul>
                <div class="code-preview">
const count = ref<number>(0)
const user = reactive<User>({ name: '', age: 0 })
                </div>
                <div class="example-actions">
                    <a href="#" class="btn btn-primary" onclick="loadExample('05-typescript-inference')">🎯 类型演示</a>
                    <a href="#" class="btn btn-secondary" onclick="viewCode('05-typescript-inference')">👀 查看代码</a>
                </div>
            </div>

            <!-- 小作业1: 温度转换器 -->
            <div class="example-card">
                <h3><span class="icon">🌡️</span> 小作业1: 智能温度转换器</h3>
                <span class="difficulty-badge difficulty-easy">初级</span>
                <p class="description">
                    综合运用所学知识，创建一个功能完整的温度转换器。支持摄氏度、华氏度双向转换，包含温度状态显示和历史记录功能。
                </p>
                <ul class="features">
                    <li>双向温度转换计算</li>
                    <li>温度状态智能显示</li>
                    <li>转换历史记录</li>
                    <li>常用温度快捷设置</li>
                </ul>
                <div class="code-preview">
const celsius = ref(0)
const fahrenheit = computed(() => {
  return (celsius.value * 9/5) + 32
})
                </div>
                <div class="example-actions">
                    <a href="#" class="btn btn-primary" onclick="loadExample('06-temperature-converter')">🌡️ 开始转换</a>
                    <a href="#" class="btn btn-secondary" onclick="viewCode('06-temperature-converter')">👀 查看代码</a>
                </div>
            </div>

            <!-- 小作业2: 待办列表 -->
            <div class="example-card">
                <h3><span class="icon">📝</span> 小作业2: 智能待办列表</h3>
                <span class="difficulty-badge difficulty-medium">中级</span>
                <p class="description">
                    创建一个功能丰富的待办列表应用，包含任务增删改查、优先级管理、自动统计和活动日志等功能。
                </p>
                <ul class="features">
                    <li>任务CRUD完整操作</li>
                    <li>优先级和状态管理</li>
                    <li>自动统计和过滤</li>
                    <li>活动日志记录</li>
                </ul>
                <div class="code-preview">
const todos = ref<Todo[]>([])
const completedCount = computed(() => 
  todos.value.filter(todo => todo.completed).length
)
                </div>
                <div class="example-actions">
                    <a href="#" class="btn btn-primary" onclick="loadExample('07-todo-list-with-stats')">📝 管理任务</a>
                    <a href="#" class="btn btn-secondary" onclick="viewCode('07-todo-list-with-stats')">👀 查看代码</a>
                </div>
            </div>

            <!-- 小作业3: 鼠标位置监听器 -->
            <div class="example-card">
                <h3><span class="icon">🖱️</span> 小作业3: 鼠标位置监听器</h3>
                <span class="difficulty-badge difficulty-hard">高级</span>
                <p class="description">
                    创建一个智能的鼠标位置监听器，实时跟踪鼠标移动，提供位置分析、历史轨迹记录和移动模式统计等高级功能。
                </p>
                <ul class="features">
                    <li>实时鼠标位置跟踪</li>
                    <li>移动轨迹历史记录</li>
                    <li>智能数据分析和统计</li>
                    <li>象限分布和速度计算</li>
                </ul>
                <div class="code-preview">
const mouseX = ref(0)
const mouseY = ref(0)
const positionHistory = ref<PositionPoint[]>([])
                </div>
                <div class="example-actions">
                    <a href="#" class="btn btn-primary" onclick="loadExample('08-mouse-position-tracker')">🖱️ 开始跟踪</a>
                    <a href="#" class="btn btn-secondary" onclick="viewCode('08-mouse-position-tracker')">👀 查看代码</a>
                </div>
            </div>
        </div>

        <div class="section-divider">
            <span>🚀 学习建议</span>
        </div>

        <div class="intro">
            <h2>💡 如何高效学习</h2>
            <p><strong>循序渐进：</strong>建议按照关卡顺序学习，每个实例都建立在前一个的基础上。不要急于求成，确保理解每个概念后再进入下一个。</p>
            <br>
            <p><strong>动手实践：</strong>不要只看代码，一定要亲自运行和修改。尝试在每个实例的基础上添加新功能，这样能更深入地理解原理。</p>
            <br>
            <p><strong>举一反三：</strong>学习完每个实例后，思考如何将这些技术应用到自己的项目中。响应式编程的思想比具体API更重要。</p>
        </div>

        <footer class="footer">
            <p>🎯 <span class="highlight">学习完成目标</span>：掌握Vue3响应式系统的核心概念，能够独立开发复杂的响应式应用</p>
            <p>📚 建议学习时间：每个实例1-2小时，总计15-20小时完成全部内容</p>
            <div class="tech-stack">
                <span class="tech-item">🔄 响应式数据</span>
                <span class="tech-item">🧮 计算属性</span>
                <span class="tech-item">👁️ 侦听器</span>
                <span class="tech-item">🎯 类型安全</span>
                <span class="tech-item">🚀 实战应用</span>
            </div>
        </footer>
    </div>

    <script>
        // 示例加载功能
        function loadExample(exampleName) {
            // 这里可以添加实际的示例加载逻辑
            const examples = {
                '01-ref-hero-example': '英雄血量和攻击状态游戏',
                '02-reactive-hero-leveling': 'Vue法师成长记',
                '03-computed-shopping-cart': '智能购物车',
                '04-watch-watchEffect-demo': '智能监控系统',
                '05-typescript-inference': 'TypeScript类型推断演示',
                '06-temperature-converter': '智能温度转换器',
                '07-todo-list-with-stats': '智能待办列表',
                '08-mouse-position-tracker': '鼠标位置监听器'
            };
            
            alert(`🎉 正在加载: ${examples[exampleName]}\n\n这是一个演示功能，实际使用时需要集成Vue运行环境。`);
            console.log(`加载示例: ${exampleName}`);
        }

        // 代码查看功能
        function viewCode(exampleName) {
            const fileName = exampleName + '.vue';
            alert(`📋 查看代码: ${fileName}\n\n实际使用时可以打开文件查看完整代码，或者集成代码高亮显示。`);
            console.log(`查看代码: ${fileName}`);
            
            // 可以尝试打开实际的Vue文件
            // window.open(`examples/${fileName}`, '_blank');
        }

        // 页面加载动画
        document.addEventListener('DOMContentLoaded', function() {
            const cards = document.querySelectorAll('.example-card');
            cards.forEach((card, index) => {
                setTimeout(() => {
                    card.style.opacity = '0';
                    card.style.transform = 'translateY(30px)';
                    card.style.transition = 'all 0.6s ease';
                    
                    setTimeout(() => {
                        card.style.opacity = '1';
                        card.style.transform = 'translateY(0)';
                    }, 100);
                }, index * 100);
            });

            // 添加滚动动画
            const observer = new IntersectionObserver((entries) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        entry.target.style.opacity = '1';
                        entry.target.style.transform = 'translateY(0)';
                    }
                });
            });

            cards.forEach(card => {
                observer.observe(card);
            });
        });

        // 添加一些交互效果
        document.querySelectorAll('.btn').forEach(btn => {
            btn.addEventListener('click', function(e) {
                // 创建点击波纹效果
                const ripple = document.createElement('span');
                const rect = this.getBoundingClientRect();
                const size = Math.max(rect.width, rect.height);
                const x = e.clientX - rect.left - size / 2;
                const y = e.clientY - rect.top - size / 2;
                
                ripple.style.cssText = `
                    position: absolute;
                    width: ${size}px;
                    height: ${size}px;
                    left: ${x}px;
                    top: ${y}px;
                    background: rgba(255, 255, 255, 0.3);
                    border-radius: 50%;
                    transform: scale(0);
                    animation: ripple 0.6s linear;
                    pointer-events: none;
                `;
                
                this.style.position = 'relative';
                this.style.overflow = 'hidden';
                this.appendChild(ripple);
                
                setTimeout(() => {
                    ripple.remove();
                }, 600);
            });
        });

        // 添加CSS动画
        const style = document.createElement('style');
        style.textContent = `
            @keyframes ripple {
                to {
                    transform: scale(4);
                    opacity: 0;
                }
            }
        `;
        document.head.appendChild(style);
    </script>
</body>
</html>